unit App.Action.TAppDefaultAppendAction;

interface

uses SmallStruct.Action,
  App.Action.TAppCustomeAction;

type
  TAppDefaultAppendAction = class(TAppCustomeAction)
  protected
    function DoPerform(ActionContext: ISSActionContext): Boolean; override;
  end;

implementation

uses SmallStruct.Configuration,
  SmallStruct.View,
  SmallStruct.Tools,
  SmallStruct.Model,
  SmallStruct.Configuration.TSSViewConfiguration;

{ TAppDefaultAppendAction }

function TAppDefaultAppendAction.DoPerform(ActionContext: ISSActionContext): Boolean;
var
  OpenCondition: ISSRecord;
begin
  Result := False;
  ActionContext.GetResponseView.GetContext.GetParameter.AppendObject((ActionContext.GetRequestView.GetContext.GetConfiguration as ISSViewConfiguration).GetPrimaryModelName, GetRequestViewPrimaryDataModel.GetObjectInstance);

  (ActionContext.GetResponseView.GetContext.GetConfiguration.GetObjectInstance as TSSViewConfiguration).SetPrimaryModelName((ActionContext.GetRequestView.GetContext.GetConfiguration as ISSViewConfiguration).GetPrimaryModelName);

  GetRequestViewPrimaryDataModel.AppendRecord;
  (ActionContext.GetResponseView as ISSDataView).InitDataSource;

  if ActionContext.GetRequestView.GetContext.GetParameter.FindObject('OPEN_CONDITION') >= 0 then
  begin
    OpenCondition := ActionContext.GetRequestView.GetContext.GetParameter.GetObject('OPEN_CONDITION') as ISSRecord;
    GetRequestViewPrimaryDataModel.GetDataSet.GetDataSet.FieldByName(OpenCondition.GetValueName(0)).AsInteger := OpenCondition.GetValue(OpenCondition.GetValueName(0));
  end;

  Result := True;
end;

end.
